<?php
$smarty->configLoad($lang . '/character.module.php');
$language = parse_ini_file($lang . '/breadcrumb.module.php', true);
$breadcrumb = $language['character'];
if(empty($_GET['charID'])) {
	$sql = 'SELECT * FROM '.DB_GAME.'.players WHERE account_id = :id';
	$dbh = $connection->prepare($sql);
	$dbh->bindValue(':id', $_SESSION['id']);
	$dbh->execute();
	foreach($dbh->fetchAll(PDO::FETCH_ASSOC) as $row) {
		$value[] = $row;
	}
	$smarty->assign('value', $value);
	$template = 'character/my.tpl';
} else {

$sql = 'SELECT * FROM '.DB_GAME.'.players WHERE id = :id';
$dbh = $connection->prepare($sql);
$dbh->bindValue(':id', $_GET['charID']);
$dbh->execute();
$row = $dbh->fetch(PDO::FETCH_ASSOC);

$char = new character;
$name = $char->getCharName($_GET['charID']);
$status = $char->showStatus($_GET['charID']);
$level	= $char->getLevel(0, $_GET['charID']);
$legion	= $char->legionName($_GET['charID']);
$class	= $char->getClass($row['player_class'], 1);
$race	= $char->getRace($row['race'], 2, 1);
$kill	= $char->getAbyssKills($_GET['charID']);
$points	= $char->getAbyssPoints($_GET['charID']);
$userID = $char->getAccountID($_GET['charID']);
$smarty->assign('name', $name);
$smarty->assign('status', $status);
$smarty->assign('level', $level);
$smarty->assign('legion', $legion);
$smarty->assign('class', $class);
$smarty->assign('race', $race);
$smarty->assign('kill', $kill);
$smarty->assign('points', $points);
$smarty->assign('userID', $userID);
$smarty->assign('charID', $_GET['charID']);



$sql = 'SELECT * FROM '.DB_GAME.'.inventory WHERE itemOwner = :itemOwner  AND isEquiped = "1" ORDER BY slot';
$dbh = $connection->prepare($sql);
$dbh->bindValue(':itemOwner', $_GET['charID']);
$dbh->execute();
foreach ($dbh->fetchAll(PDO::FETCH_ASSOC) as $line) {

	switch ($line['slot']) {
		default: continue;

		case 1: $name = 'hauptwaffe';
			break;
		case 2: $name = 'zweitwaffe';
			break;
		case 4: $name = 'helm';
			break;
		case 8: $name = 'brustbekleidung';
			break;
		case 16: $name = 'handschuhe';
			break;
		case 32: $name = 'stiefel';
			break;
		case 64: $name = 'linkero';
			break;
		case 128: $name = 'rechtero';
			break;
		case 256: $name = 'linkerr';
			break;
		case 512: $name = 'rechterr';
			break;
		case 1024: $name = 'schulterschutz';
			break;
		case 2048: $name = 'halskette';
			break;
		case 4096: $name = 'hose';
			break;
		case 8192: $name = 'machtscherben';
			break;
		case 16384: $name = 'machtscherben1';
			break;
		case 32768: $name = 'flugel';
			break;
		case 65536: $name = 'gurtel';
			break;
		case 131072: $name = 'hauptwaffeo';
			break;
		case 262144: $name = 'zweitwaffeo';
			break;
	}
	$smarty->assign($name, $line['itemId']);
}
$inv = '';
$sql = 'SELECT * FROM '.DB_GAME.'.inventory WHERE itemOwner = :owner AND itemLocation = "0" AND isEquiped = "0"';
$dbh = $connection->prepare($sql);
$dbh->bindValue(':owner', $_GET['charID']);
$dbh->execute();
foreach($dbh->fetchAll(PDO::FETCH_ASSOC) as $line) {
	$inv[] = $line;
}
$smarty->assign('inv', $inv);
$che = '';
$sql = 'SELECT * FROM '.DB_GAME.'.inventory WHERE itemOwner = :owner AND itemLocation = "1" AND isEquiped = "0"';
$dbh = $connection->prepare($sql);
$dbh->bindValue(':owner', $_GET['charID']);
$dbh->execute();
foreach($dbh->fetchAll(PDO::FETCH_ASSOC) as $line) {
	$che[] = $line;
}
$smarty->assign('che', $che);
$template = 'character/index.tpl';
}
?>
 
